<!DOCTYPE html>
<html>
<head>
    <title>操作记录查看</title>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <script type="text/javascript">
        var path = window.document.location.href;
        var pathName = window.document.location.pathname;
        var hostPath = path.substring(0, path.indexOf(pathName));
        var projectName = pathName.substring(0, pathName.substr(1).indexOf("/") + 1);
        document.write('<scr' + 'ipt src="' + projectName + '/js/html/header.js"></scr' + 'ipt>');
        document.write('<scr' + 'ipt src="' + projectName + '/js/jquery-easyui-datagridview/datagrid-detailview.js"></scr' + 'ipt>');
    </script>
</head>
<body>
<table id="dg" style="width: auto; height: auto" fitColumns="true">
    <thead>
    <tr>
        <!-- 	<th field="id" data-options="hidden:true">ID</th> -->
        <th field="objectName" align="right"
            data-options="
				sortable:true,
				remoteSort:false
				">数据对象
        </th>
        <th field="id" align="right"
            data-options="
				sortable:true,
				remoteSort:false
				">数据ID
        </th>
        <th field="periods" align="right"
            data-options="
				sortable:true,
				remoteSort:false
				">数据期数
        </th>
        <th field="timeStamp" width="100" align="right"
            data-options="
				sortable:true,
				remoteSort:false"
        >处理时间戳
        </th>
        <th field="conductUser" id="conductUser" width="100" align="right"
            data-options="
				sortable:true,
				remoteSort:false"
        >最后修改人
        </th>
        <th field="conductTime" id="conductTime" width="100" align="right"
            data-options="
				sortable:true,
				remoteSort:false"
        >最后修时间
        </th>
    </thead>
</table>
<div id="dg-buttons" style="height: auto">
    <div>
        <span>&nbsp;&nbsp;&nbsp;&nbsp;选择:</span>
        <input type="text" id="searchKey" name="searchKey" class="easyui-combobox"/>
        <span>等于:</span>
        <input type="text" id="searchValue" name="searchValue" class="easyui-validatebox"/>
        <a href="javascript:void(0)" class="easyui-linkbutton" iconCls="icon-search" onclick="dgop.find()">查询</a>
    </div>
</div>
<script>
    var initd = {
        queryDataURL: "/commonInfo/alterRecordQuery",
        dg: $('#dg'),
        dataDicList: {'ORG': ['orgId'], 'USER': ['conductUser']}
    };

    initd.dg.datagrid({
        url: projectName + initd.queryDataURL,
        method: 'post',
        iconCls: 'icon-search',
        striped: true,
        nowrap: true,
        border: true,
        idField: 'id',
        singleSelect: true,
        rownumbers: true,
        fit: false,
        fitColumns: true,
        loadMsg: '数据加载中……',
        toolbar: '#dg-buttons',
        pagination: true,
        pageNumber: 1,
        pageList: [10, 30, 50],
        queryParams: {
            dataDicList: JSON.stringify(initd.dataDicList)
        },
        loader: function (param, success, error) {
            $.ajax({
                type: "POST",
                url: projectName + initd.queryDataURL,
                data: JSON.stringify(param),
                dataType: "json",
                contentType: "application/json;charset=utf-8",
                success: function (data) {
                    success(data);
                },
                error: function (err, status) {
                    $.messager.alert("错误提示", '[' + err.status + ']' + err.responseText);
                    initd.dg.datagrid('loaded');
                }
            });
        },
        loadFilter: amsDataFilter,
        onLoadError: function (err) {
            errorMsgAlert(err);
        },
        view: detailview,
        detailFormatter: function (rowIndex, rowData) {
            var lastList = rowData.lastList;
            var html = '<div style="width:1000px; height:80px; overflow:scroll;"><table border="1"><tr>';
            html = html + '<td style="border:1; width:100px;">&emsp;&emsp;&emsp;&emsp;</td>'
            for(let key  in lastList[0]){
                html = html + '<td style="border:1; width="100">' + key + '</td>'
            }
            html = html + '<td>&emsp;</td></tr><tr>'
            html = html + '<td>当前值</td>'
            for(let key  in lastList[0]){
                html = html + '<td style="border:1" width="100">' + lastList[0][key] + '</td>'
            }
            html = html + '<td>&emsp;</td></tr><tr>'
            html = html + '<td>历史值</td>'
            for(let key  in lastList[1]){
                html = html + '<td style="border:1" width="100">' + lastList[1][key] + '</td>'
            }
            html = html + '<td>&emsp;</td></tr></table></div>';
            return html;
        }

    });

    /** DATAGRID 分页工具栏及分页查询 **/
    var pager = initd.dg.datagrid('getPager');
    $(pager).pagination({
        loading: true,
        beforePageText: '第',
        afterPageText: '页  共{pages}页',
        displayMsg: '显示条数{from}~{to},共{total}条记录',
        onSelectPage: function (pageNum, pageSize) {
            initd.dg.datagrid('loading');
            $.ajax({
                type: "POST",
                url: initd.queryDataURL,
                data: JSON.stringify({
                    'page': pageNum,
                    'rows': pageSize
                }),
                dataType: "json",
                contentType: "application/json;charset=utf-8",
                success: function (data) {
                    if (!data.success) {
                        alert(data.message);
                        return;
                    }
                    if (data != null) {
                        initd.dg.datagrid('loadData', data);
                        initd.dg.datagrid('loaded');
                    }
                },
                error: function (err, status) {
                    initd.dg.datagrid('loaded');
                    errorMsgAlert(err);
                }
            });
        }
    });
</script>
</body>
</html>

